@extends('layouts.root')

@section('title' , '客户后台')


<!-- 主体内容 -->
@section('contents')

    <!-- 主体内容 -->
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card layui-form">
                    <div class="layui-card-header">设置微信资料</div>
                    <div class="layui-card-body" pad15>
                        <div class="layui-form" lay-filter="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">微信名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="wechat_name" value="{{ $users->wechat_name ?? '' }}" lay-verify="required" placeholder="微信名称" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">微信帐户</label>
                                <div class="layui-input-block">
                                    <input type="text" name="wechat_account" value="{{ $users->wechat_account ?? '' }}" lay-verify="required" autocomplete="off" placeholder="微信帐户" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">合作伙伴身份（PID）</label>
                                <div class="layui-input-block">
                                    <input type="text" name="wechat_parentid" value="{{ $users->wechat_parentid ?? '' }}" lay-verify="required" autocomplete="off" placeholder="合作身份者ID，签约账号，以2088开头" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">MD5密钥</label>
                                <div class="layui-input-block">
                                    <input type="text" name="wechat_key" value="{{ $users->wechat_key ?? '' }}" lay-verify="required" autocomplete="off" placeholder="MD5密钥，安全检验码" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="setmyinfo">提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection


@section('scripts')
    <script>
        layui.config({
            base: '/layuiadmin/'
        }).extend({
            index: 'lib/index',
        }).use(['index','form','upload'],function(){
            var $ = layui.$
                ,form = layui.form
                ,upload = layui.upload
                ,layer = layui.layer;

            layer.closeAll();
            //普通图片上传
            form.on('submit(setmyinfo)',function(data){
                var field = data.field;

                $.ajax({
                    @if($users)
                    method:'PATCH',
                    url: '{{ route('zbsuser.alipay.update' , $users->user_id) }}'
                    @else
                    method:'POST',
                    url: '{{ route('zbsuser.alipay.store') }}'
                    @endif
                    ,data: field
                    ,dataType:'json'
                    ,success:function(res){
                        if (res.code){
                            layer.msg(res.msg , {icon:6,time:1000},function(){
                                layer.closeAll();
                            });
                        }else{
                            layer.msg(res.msg , {icon:5,time:1000},function(){
                            });
                        }

                    }
                    ,error:function(err){
                        var parseJSON = err.responseJSON.errors;
                        var html = '';
                        $.each(parseJSON , function(k , v){
                            html += v + '<br>';
                        });
                        layer.msg(html , {icon:5,time:1500})
                    }
                })
            });



        });
    </script>
@endsection